import assign from 'object-assign';
import {observable, useStrict, action, runInAction} from 'mobx';
import {browserHistory} from 'react-router';

class UserStore {
    @observable uploadImgUrl;
    @observable uploadImgStyleTop = 0;
    @observable uploadImgStyle = {
        top : 0,
        left : 0
    };

    @observable cardImgUrl;
    @observable cardData = {
        canvas: null
    };

    @observable btnShowState = false;
    @observable selectedType;
    @observable cardType = 'up';

    @action changeBtnLists(param) {
        if(param == 'show'){
            this.btnShowState = true;
        }else if(param == 'hide'){
            this.btnShowState = false;
        }
    }

    @action turnCard(type) {
        this.cardType = type;
    }

    @action changeSeletedType(type) {
        this.selectedType = type;
        if(type === 0){
            browserHistory.push('/m/citiccard/selectImg');
        }else if(type === 1){
            browserHistory.push('/m/citiccard/applyCard');
        }
    }



    @action xuanZeTuPian(imgUrl) {
        // let history = qs.parse(window.location.search.substring(1)).return || '/';
        this.uploadImgUrl = imgUrl;
        browserHistory.push('/m/citiccard/editImg');
    }
    @action liJiShenQing(imgUrl) {
        // let history = qs.parse(window.location.search.substring(1)).return || '/';
        this.cardImgUrl = imgUrl;
        browserHistory.push('/static/citiccard/submit');
    }

    @action changeUploadImgStyle(options) {
        if(this.uploadImgUrl){
            assign(this.uploadImgStyle,options);
        }
        // this.uploadImgStyleTop = options.top;
    }

}
const User = new UserStore();
export default User;
